home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 7
/
Apprentice-Release7.iso
/
Demos
/
A.D. Software
/
OOFILE 1.3b4d6.sit
/
OOFILE 1.3b4d6
/
OOFRep demo
/
RepTestApp.cp
< prev
next >
Wrap
Text File
|
1997-05-08
|
8KB
|
278 lines
// ===========================================================================
// RepTestApp.cp Derived heavily from the Dashboard Starter
// ===========================================================================
//
#include "RepTestApp.h"
#include <LApplication.h>
#include <LGrowZone.h>
#include <LWindow.h>
#include <UDrawingState.h>
#include <UMemoryMgr.h>
#include <URegistrar.h>
#include "oofGrphs.h"
#include "oofRepPPWindow.h"
#include "oofRepMacPrint.h"
#ifdef OOF_SmartHeap
#include "smrtheap.hpp"
#endif
// ===========================================================================
// * Main Program
// ===========================================================================
void main()
{
// Set Debugging options
SetDebugThrow_(debugAction_Alert);
SetDebugSignal_(debugAction_Alert);
InitializeHeap(3); // Initialize Memory Manager
// Parameter is number of Master Pointer
// blocks to allocate
// Initialize standard Toolbox managers
UQDGlobals::InitializeToolbox(&qd);
new LGrowZone(20000); // Install a GrowZone function to catch
// low memory situations.
// Parameter is size of reserve memory
// block to allocated. The first time
// the GrowZone function is called,
// there will be at least this much
// memory left (so you'll have enough
// memory to alert the user or finish
// what you are doing).
RepTestApp theApp; // Create instance of your Application
theApp.Run(); // class and run it
}
// ---------------------------------------------------------------------------
// * RepTestApp
// ---------------------------------------------------------------------------
// Constructor
RepTestApp::RepTestApp()
{
}
// ---------------------------------------------------------------------------
// * RepTestApp
// ---------------------------------------------------------------------------
// Destructor
RepTestApp::~RepTestApp()
{
}
// ---------------------------------------------------------------------------
// Initialize
// ---------------------------------------------------------------------------
void
RepTestApp::Initialize()
{
oofRep* SimpleReport = new oofRep;
oofRep* SimpleReportWithNotes = new oofRep;
oofRep* BreakReport = new oofRep;
PatientVisits = new dbRelationship(Patients.Visits, Visits.Patient);
// RAM Backend
theDB.newConnection();
Patients.AddTestData();
Students.AddTestData();
Patients.setSortOrder(Patients.LastName);
Patients.selectAll();
Students.setSortOrder(dbSorter() << Students.Name << Students.Subject);
dbView Sview(Students, false);
Sview << Students.Name << Students.Subject << Students.Mark;
// OK - Let's get Powerplant to work
// Register the functions to create our custom Pane classes
oofRepWindow::RegisterClass();
// Do the Stuff !
//****** global page footer *******
oofRepLayoutBand* footer = new oofRepLayoutBand;
*footer
<< "CLINIC"
<< oofRepTextBlock(
ostrstream() << "Printed by MANAGER on " << dbDate::today
).align(oofRepBlock::alignRight);
// if attaching to a report directly, do the following
// SimpleReport.pageFooters() << new oofRepLineBand << footer;
oofRep::defaultSettings()->defaultPageFooters() << new oofRepLineBand << footer;
//****** simple list *******
{
oofRepLayoutBand* header = new oofRepLayoutBand;
header->textStyle("Helvetica", 18, italic);
*header << "Dr Doolot's Clinic\n" << "Patient List\n";
// *header << Patients.LastName << " " << Patients.Othernames;
SimpleReport->pageHeaders() << header << new oofRepLineBand << new oofRepSpaceBand(10);
SimpleReport->body(
new oofRepViewBand(
dbView(Patients, false) << Patients.LastName << Patients.Othernames,
true //Boxed
)
);
SimpleReport->getLocalSettings()->drawHeadingsDownToLevel(0); // no headings on views at all
oofRepWindow::CreateWindow(this, SimpleReport);
}
//****** simple list with extra view band used to provide notes at the bottom *******
{
oofRepLayoutBand* header = new oofRepLayoutBand;
header->textStyle("Helvetica", 18, italic);
*header << "Dr Doolot's Clinic\n" << "Patient List\n";
// *header << Patients.LastName << " " << Patients.Othernames;
SimpleReportWithNotes->pageHeaders() << header; // no line as it looks a bit silly over a boxed report without a space
dbView nilView; // lacks a table, just provides a place to hang some text comments
nilView
<< "This is the first largish text comment\nwith embedded linefeed"
<< "This is a second comment which should appear alongside the first comment.";
oofRepViewBand* bodyBand = new oofRepViewBand(
dbView(Patients, false) << Patients.LastName << Patients.Othernames,
true //Boxed
);
bodyBand->footers() << new oofRepSpaceBand(20) << new oofRepViewBand(nilView);
SimpleReportWithNotes->body(bodyBand);
oofRepWindow::CreateWindow(this, SimpleReportWithNotes);
}
//****** simple list with graph and break after each record for 2nd list *******
{
oofRepLayoutBand* header = new oofRepLayoutBand;
header->textStyle("Helvetica", 18, italic);
*header << "Dr Doolot's Clinic\n" << "Patient List With Details\n";
BreakReport->pageHeaders() << header << new oofRepLineBand(2);
dbView SimplePatients(Patients, false);
SimplePatients << Patients.LastName << Patients.Othernames;
SimplePatients.colSizer()->setFixedWidth(0, 80); // pixels
oofRepViewBand* body = new oofRepViewBand(SimplePatients);
oofRepViewBand* body2 = new oofRepViewBand(
dbView(Patients.Visits, false) << Patients.Visits->VisitDate << Patients.Visits->Why
);
oofRepGraphBand* graph = new oofRepGraphBand(
new oofColumnGraph(&Sview),
300,300,500, "Test Graph"
);
body2->headers() << new oofRepSpaceBand(4); // small gap before details
body2->footers() << new oofRepSpaceBand(32); // large gap after
body->footerBreaks() << new oofRepBreakEveryRecord(body2);
body->footers() << graph;
BreakReport->body(body);
/* THPrint myTHPrint=UPrintingMgr::CreatePrintRecord();
UPrintingMgr::AskPageSetup(myTHPrint);
if(UPrintingMgr::AskPrintJob(myTHPrint)) {
BreakReport->draw(oofRepMacPrint(myTHPrint));
}
::DisposeHandle((Handle)myTHPrint);
*/
oofRepWindow::CreateWindow(this, BreakReport);
}
}
// ---------------------------------------------------------------------------
// * ObeyCommand
// ---------------------------------------------------------------------------
// Respond to commands
Boolean
RepTestApp::ObeyCommand(
CommandT inCommand,
void *ioParam)
{
Boolean cmdHandled = true;
switch (inCommand) {
default:
cmdHandled = LApplication::ObeyCommand(inCommand, ioParam);
break;
}
return cmdHandled;
}
// ---------------------------------------------------------------------------
// * FindCommandStatus
// ---------------------------------------------------------------------------
// Pass back status of a (menu) command
void
RepTestApp::FindCommandStatus(
CommandT inCommand,
Boolean &outEnabled,
Boolean &outUsesMark,
Char16 &outMark,
Str255 outName)
{
switch (inCommand) {
default:
LApplication::FindCommandStatus(inCommand, outEnabled, outUsesMark,
outMark, outName);
break;
}
}
// ===========================================================================
// * Student test data
// ===========================================================================
void dbStudent::Add(const char *name, const char *subject, const long mark)
{
newRecord();
Name = name;
Subject = subject;
Mark = mark;
saveRecord();
}
void dbStudent::AddTestData()
{
Add("Alice Chan", "Maths", 62);
Add("Alice Chan", "Social Studies", 72);
Add("Alice Chan", "English", 65);
Add("Alice Chan", "Science", 82);
Add("Kathy Robins", "Maths", 82);
Add("Kathy Robins", "Social Studies", 54);
Add("Kathy Robins", "English", 44);
Add("Kathy Robins", "Science", 75);
Add("Brett Baker", "Maths", 65);
Add("Brett Baker", "Social Studies", 78);
Add("Brett Baker", "English", 64);
Add("Brett Baker", "Science", 72);
Add("Jack Smith", "Maths", 71);
Add("Jack Smith", "English", 56);
Add("Jack Smith", "Science", 81);
Add("Jack Smith", "Social Studies", 35);
}